package org.deltaset.meta.internal;

import java.lang.annotation.Annotation;
import java.util.Map;
import org.deltaset.meta.MetaField;

/**
 *
 * @author dmakariev
 */
class MetaFieldImpl implements MetaField {

    MetaFieldImpl(BeanProperty beanProperty, String propertyLabelKey, String propertyType, Map<String, String> params) {
        //String propertyName,Class originalType, Annotation[] originalAnnotations
        this.propertyName = beanProperty.getFieldName();
        this.propertyLabelKey = propertyLabelKey;
        this.propertyType = propertyType;
        this.params = params;
        this.originalType = beanProperty.getFieldType();
        this.genericType = beanProperty.getFieldGenericType();
        this.originalAnnotations = beanProperty.getFieldAnnotations();
    }
    private final String propertyName;
    private final String propertyType;
    private final String propertyLabelKey;
    private final Map<String, String> params;
    private final Class originalType;
    private final Class genericType;
    private final Annotation[] originalAnnotations;

    static String fieldName(int index) {
        return "p" + index;
    }

    @Override
    public Map<String, String> getParams() {
        return params;
    }

    @Override
    public String getPropertyName() {
        return propertyName;
    }

    @Override
    public String getPropertyLabelKey() {
        return propertyLabelKey;
    }

    @Override
    public String getPropertyType() {
        return propertyType;
    }

    @Override
    public Class getOriginalType() {
        return originalType;
    }

    @Override
    public Annotation[] getOriginalAnnotations() {
        return originalAnnotations;
    }

    @Override
    public Class getGenericType() {
        return genericType;
    }

    @Override
    public String toString() {
        return "MetaField{" + "propertyName=" + propertyName + ", propertyLabelKey=" + propertyLabelKey + ", originalType=" + originalType + ", propertyType=" + propertyType + '}';
    }
}
